package com.waves.design.flyweight;

/**
 * 享元模式
 */
public class FlyweightTest {
    public static void main(String[] args) {
        IgoChessman black1, black2, black3, white1, white2;
        IgoChessmanFactory factory = IgoChessmanFactory.getInstance();
        black1 = factory.getIgoChessman("b");
        black2 = factory.getIgoChessman("b");
        black3 = factory.getIgoChessman("b");
        white1 = factory.getIgoChessman("w");
        white2 = factory.getIgoChessman("w");
        System.out.println(black1 == black2);
        System.out.println(white1 == white2);

        black1.display();
        black2.display();
        black3.display();
        white1.display();
        white2.display();
    }

}
